<template>
  <el-dialog :title="title" :visible.sync="showDialog" top="0" :close-on-click-modal="false" @close="cancel">
    <div v-if="list.length !== 0" class="material-list">
      <div v-for="(item, index) in list" :key="index" class="list-item">
        <span>加工原料：{{ item.materialName }}</span>
        <span>预计领料数量：{{ item.expectNum }} {{ item.unitName || item.material.unitName }}</span>
      </div>
    </div>
    <span v-if="list.length === 0">暂无数据</span>
    <div slot="footer" class="dialog-footer">
      <el-button class="savebtn" @click="cancel()">关 闭</el-button>
    </div>
  </el-dialog>
</template>

<script>
export default {
  props: {
    value: Boolean,
    list: {
      type: Array,
      default: () => {
        return [];
      }
    },
    title: {
      type: String,
      default: '预期原料量'
    }
  },
  data() {
    return {
      showDialog: false
    };
  },
  watch: {
    value(v) {
      this.showDialog = v;
    }
  },
  mounted() {},
  methods: {
    close() {
      this.$emit('input', false);
    },
    cancel() {
      this.$emit('input', false);
    }
  }
};
</script>

<style lang="scss" scoped>
.material-list {
  padding: 24px 47px;
  box-sizing: border-box;
  background: #e9f8fd;
  border-radius: 10px;
  border: 1px solid #c9e0e7;
  .list-item {
    margin-bottom: 10px;
    display: flex;
    align-items: center;
    span {
      flex: 1;
    }
    &:last-of-type {
      margin-bottom: 0;
    }
  }
}
</style>
